import * as CONSTANT from '../constant'

//counter
//函数方便传值 给reducer
export const increamentAction = ()=>({type:CONSTANT.INCREMENT})

export const increamentActionAsync = ()=>{
    const delay  = (ms)=>new Promise(resolve=>setTimeout(resolve,ms))
    return async (dispatch,getState)=>{
        
        //模拟异步操作
        await  delay(2000)

        //同步派发到 reducer
        dispatch(increamentAction())
    }
}

export const decreamentAction = ()=>{
    return {type:CONSTANT.DECREMENT}
}